package com.java.example.util

import android.content.Context
import android.speech.tts.TextToSpeech

object SpeakUtils {
    private var tts: TextToSpeech? = null
    fun init(context: Context) {
        tts = TextToSpeech(context) { }
    }

    fun speak(str: String) {
        stopSpeak()
//        if (BuildConfig.DEBUG) {
            tts?.speak(str, TextToSpeech.QUEUE_FLUSH, null, null)
//        }
    }

    fun stopSpeak() {
        tts?.stop()
    }
}